package com.wqr.mobile.android.ui.menu;

import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnCreateContextMenuListener;
import android.widget.Button;
import android.widget.Toast;

import com.wqr.mobile.android.ui.AbsFragmentActivity;
import com.wqr.mobile.android.ui.R;

public class ContextMenuExample extends AbsFragmentActivity implements OnCreateContextMenuListener {

	Button mButton1;

	@Override
	protected void setUp() {
		setContentView(R.layout.activity_context_menu);
		mButton1 = (Button) findViewById(R.id.button1);
		mButton1.setOnCreateContextMenuListener(this);
	}

	public void clickAction(View v) {
		openContextMenu(v);
	}

	@Override
	protected void destory() {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onContextItemSelected(MenuItem item) {
		Toast.makeText(this, "item-->" + item.getTitle(), 0).show();
		return super.onContextItemSelected(item);
	}

	@Override
	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
//		menu.setHeaderIcon(R.drawable.icon) ;
//		menu.add(0, 0, 0, "用户登陆");
//		menu.add(0, 1, 1, "个人信息设定");
//		menu.add(0, 2, 2, "隐私设定");
		Button button = new Button(this) ;
		button.setText("ContextMenu") ;
		menu.setHeaderView(button) ;
		menu.setHeaderTitle("个人信息设定") ;
		super.onCreateContextMenu(menu, v, menuInfo);
	}

}
